import { AtTag, AtDivider } from 'taro-ui';
import { View, Text } from '@tarojs/components';
import "taro-ui/dist/style/components/divider.scss";
import "taro-ui/dist/style/components/tag.scss";
import css from './index.module.less';
import './index.less';

export default function SurveyCard(props) {
    //投票状态
    const status = ['已结束', '未开始', '进行中'];

    const { voteTitle, voteStatus, sponsorName, voteBeginTime, voteEndTime } = props.info;
    let tagColor = '';
    if (voteStatus === 0) {
        tagColor = 'red';
    }
    if (voteStatus === 1) {
        tagColor = 'rgb(24,144,255)';
    }
    if (voteStatus === -1) {
        tagColor = 'gray';
    }

    return (
        <View className={css.card}>
            <View className={css.topInfo}>
                <Text className={css.title}>{voteTitle}</Text>
                <AtTag circle className={css.tag} customStyle={{ background: tagColor }} size='small'>{status[voteStatus + 1]}</AtTag>
            </View>
            <View className={css.bottomInfo}>
                <View>发起人：{sponsorName}</View>
                <View className={css.time}>{voteBeginTime} - {voteEndTime}</View>
            </View>
            <AtDivider content='' height={20} />
        </View>
    );
}
